package com.rankeiot.core.data;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;

import java.util.HashMap;
import java.util.Map;

public class PropMap<V> extends HashMap<Object,V> implements ValueGetter<V> {
    private static CopyOptions copyOptions=new CopyOptions();
    static {
        copyOptions.setIgnoreCase(true);
        copyOptions.setIgnoreNullValue(true);
        copyOptions.setIgnoreError(true);
    }
    public PropMap(){}
    public PropMap(Map m){
        super(m);
    }
    public PropMap(int initialCapacity){
        super(initialCapacity);
    }
    public <T> T get(String key,T bean){
        //BeanUtil.copyProperties();
        Object object = get(key);
        if(object==null){
            return null;
        }



        BeanUtil.copyProperties(object,bean,copyOptions);
        return bean;
    }
    public <T> void fillTo(T bean){
        BeanUtil.fillBeanWithMap(this,bean,true);
    }
    public void fill(Object bean){
        BeanUtil.copyProperties(bean, this,copyOptions);
    }
}
